package com.som.bean.data3;

import com.som.bean.IpAddressBase;

/**
 * 格式1：IP, 信息(sheet页的名称为IP)
 * 
 * @author liujun
 * @date 2016年4月8日
 * @verion 0.0.1
 */
public class IpAddressInfo extends IpAddressBase implements Comparable<IpAddressInfo>
{
	/**
	 * 信息
	 */
	private String msginfo;

	public String getMsginfo()
	{
		return msginfo;
	}

	public void setMsginfo(String msginfo)
	{
		this.msginfo = msginfo;
	}

	@Override
	public String toString()
	{
		StringBuilder builder = new StringBuilder();
		builder.append("IpAddressInfo [msginfo=");
		builder.append(msginfo);
		builder.append(", toString()=");
		builder.append(super.toString());
		builder.append("]");
		return builder.toString();
	}

	/**
	 * 进行排序接口实现
	 */
	public int compareTo(IpAddressInfo o)
	{
		String currip = this.getIpaddress();
		String compIp = o.getIpaddress();

		String[] currIpArrays = currip.split("\\.");
		String[] compIPArrays = compIp.split("\\.");
		
		if(null != currIpArrays && compIPArrays != null)
		{
			int ipcomp1 = 0;
			int ipcomp2 = 0;
			
			for (int i = 0; i < compIPArrays.length; i++)
			{
				ipcomp1 = Integer.parseInt(currIpArrays[i]);
				ipcomp2 = Integer.parseInt(compIPArrays[i]);
				
				if(ipcomp1 > ipcomp2)
				{
					return 1;
				}
				else if(ipcomp1 < ipcomp2)
				{
					return -1;
				}
			}
		}
	

		return 0;
	}

}
